<?php
Class dataobject
{
 public $name;    //username (string)
 public $pass;   //password (string)
 public $host; //connection (string)
 public $db; //database (string)
 public $tb; //table (string)
 public $qy; //query (string)
 public $rs; //resource (resource id)
 public $fd; //feed (string)

public function __construct($ip)
{
 $name='$admin';
 $pass='$passwd';
 self::_setname($name);
 self::_setpass($pass);
 self::_setconn($ip);
 $conn=$ip;
}
public function _setname($name)
{
 $this->name=$name;
}
public function _setpass($pass)
{
 $this->pass=$pass;
}
public function _setconn($conn)
{
 $this->host=$conn;
}
public function _setdb($db)
{
 $this->db=$db;
}
public function _settb($tb)
{
 $this->tb=$tb;
}
public function _setqy($qy)
{
 $this->qy=$qy;
}
public function _setrs($rs)
{
 $this->rs=$rs;
}
public function _setfd($fd)
{
 $this->fd=$fd;
}
public function _getfd()
{
 return $this->fd;
}
public function _getrs()
{
 return $this->rs;
}
public function _getqy()
{
 return $this->qy;
}
public function _gettb()
{
 return $this->tb;
}
public function _getdb()
{
 return $this->db;
}
public function _getconn()
{
 return $this->host;
}
public function _getpass()
{
 return $this->pass;
}
public function _getname()
{
 return $this->name;
}
public function connect($db)
{
 // Using "localhost" as hostname instead of the IP that was passed
 $id = mysqli_connect("localhost", $this->name, $this->pass);
 
 if (!$id) {
    // Error handling
    echo "Connection failed: " . mysqli_connect_error();
    return false;
 }
 
 self::_setrs($id);
 self::_setdb($db);
 self::select($db);
 return $id;
}
public function select($db)
{
 // Corrected mysqli_select_db call with both connection and database
 mysqli_select_db($this->rs, $db);
}
public function close($id)
{
 mysqli_close($id);
}
public function run($sql)
{
 // Corrected parameter order for mysqli_query
 return mysqli_query($this->rs, $sql);
}
public function grab_assoc($id)
{
 return mysqli_fetch_assoc($id);
}
public function grab_array($id)
{
 return mysqli_fetch_array($id);
}
public function grab_rows($id)
{
 return mysqli_fetch_rows($id);
}
public function setcols($id)
{
 return self::_col_count($id);
}
public function setrows($id)
{
 return self::_row_count($id);
}
public function _col_count($id)
{
 return mysqli_num_fields($id);
}
public function _row_count($id)
{
 return mysqli_num_rows($id);
}
}
?>